package com.ashapo.pattern.pattern022strategy;

//第4步
//使用上下文- Context 在更改其策略时查看行为更改。

public class StrategyPatternDemo {

    /**
     * 策略模式
     * @param args
     */
    public static void main(String[] args) {
        Context context = new Context(new OperationAdd());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        context = new Context(new OperationSubstract());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));

        context = new Context(new OperationMultiply());
        System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
    }
}
